/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.toools.gwt.wmc.client.container.gui;

import com.google.gwt.user.client.rpc.AsyncCallback;
import java.util.Collection;
import org.toools.gwt.widget.client.bc.BasicControl;
import org.toools.gwt.widget.client.bc.BasicList;
import org.toools.gwt.widget.client.bc.BasicListener;
import org.toools.gwt.widget.client.bc.BusinessObjectPanel;
import org.toools.gwt.widget.client.cloud.TagVO;
import org.toools.gwt.wmc.client.container.ContainerServiceAsync;
import org.toools.gwt.wmc.jpa.CompanyPart;
import org.toools.gwt.wmc.jpa.Container;
import org.toools.gwt.wmc.jpa.Disposer;

/**
 *
 * @author Manuel
 */
public class ContainerControl extends BasicControl{

    public ContainerControl(ContainerServiceAsync service, CompanyPart cp) {
        super(service, new org.toools.gwt.widget.client.util.Account());
        Collection<Container> containers = cp.getContainers();
        if (containers != null) {
            setTags(getTagVO(containers.toArray()));
        }
    }

    public ContainerControl(ContainerServiceAsync service, Disposer d) {
        super(service, new org.toools.gwt.widget.client.util.Account());
        Collection<Container> containers = d.getContainers();
        if (containers != null) {
            setTags(getTagVO(containers.toArray()));
        }
    }

    public BusinessObjectPanel createBasicPanel(Object o) {
        return new ContainerPanel(o);
    }
    public BasicListener createBasicListener() {
        return new ContainerListener(this);
    }
    public BasicList createBasicList() {
        ContainerList al = new ContainerList(new TagVO[]{}, this);
        return al;
    }
    public TagVO getTagVO(Object bp) {
        Container c = (Container) bp;
        TagVO result = new TagVO("" + c.getId(), c.getName(), 0, 0);
        result.setAttachedBusinessObject(c);
        return result;
    }
    @Override
    public String getFilterMessage() {
        return "search by name";
    }
    @Override
    public String getTitle() {
        return "Containers";
    }
    @Override
    public void addSortItem() {
        getSortListBox().clear();
        getSortListBox().addItem("name");
    }

}
